<template>
  <el-row class="container">
    <el-col :span="24" class="header">
      <el-col class="logo" :class="{collapse:isCollapse}"><span :class="{hide:isCollapse}">桂林名医网</span></el-col>
      <el-col class="tools">
        <div class="tools-content" @click.prevent="collapse">
					<i class="el-icon-s-unfold" v-if="isCollapse"></i>
          <i class="el-icon-s-fold" v-else></i>
				</div>
      </el-col>
      <el-col class="user-info">
        <el-dropdown style="height:44px;">
					<span class="el-dropdown-link userinfo-inner" style="color:#fff;font-size:18px;">{{username}}<i class="el-icon-arrow-down el-icon--right"></i></span>
					<el-dropdown-menu slot="dropdown">
            <!-- <el-dropdown-item><span @click="showModifyPwd">修改密码</span></el-dropdown-item> -->
						<el-dropdown-item><span @click="loginOut">退出登录</span></el-dropdown-item>
					</el-dropdown-menu>
				</el-dropdown>
      </el-col>
    </el-col>
    <el-col :span="24" class="main">
     <!-- <el-scrollbar style="height:100%"> -->
        <aside class="aside-menu" :class="{collapse:isCollapse}">
          <vue-scroll :ops="ops1">
        <el-menu 
        class="el-menu"
         :collapse="isCollapse"
          :default-active="$route.path"
           unique-opened 
           router
           background-color="#222d32"
           text-color="#b8c7ce"
           active-text-color="#fff"
           >
          <!-- <el-menu-item index="/count">
            <i class="el-icon-s-data"></i>
            <span slot="title">统计</span>
          </el-menu-item> -->
          <!-- <el-submenu index="2">
            <template slot="title">
              <i class="el-icon-user"></i>
              <span slot="title">用户管理</span>
            </template>
            <el-menu-item index="/member">
              <i class="el-icon-user-solid"></i>
              <span slot="title">会员管理</span>
            </el-menu-item>
            <el-menu-item index="/consumer">
              <i class="el-icon-menu"></i>
              <span slot="title">用户列表</span>
            </el-menu-item>
            <el-menu-item index="/apply">
              <i class="el-icon-s-order"></i>
              <span slot="title">入会申请</span>
            </el-menu-item>
            <el-menu-item index="/integralListManagement">
              <i class="el-icon-receiving"></i>
              <span slot="title">积分管理</span>
            </el-menu-item>
            <el-menu-item index="/integral">
              <i class="el-icon-notebook-2"></i>
              <span slot="title">积分榜</span>
            </el-menu-item>
          </el-submenu>
          <el-submenu index="3">
            <template slot="title">
              <i class="el-icon-money"></i>
              <span slot="title">财务管理</span>
            </template>
            <el-menu-item index="/income">
              <i class="el-icon-bank-card"></i>
              <span slot="title">收支管理</span>
            </el-menu-item>
            <el-menu-item index="/payment">
              <i class="el-icon-postcard"></i>
              <span slot="title">缴费管理</span>
            </el-menu-item>
            
            <el-menu-item index="/cost">
              <i class="el-icon-coin"></i>
              <span slot="title">费用审核</span>
            </el-menu-item>
            <el-menu-item index="/assets">
              <i class="el-icon-office-building"></i>
              <span slot="title">固定资产管理</span>
            </el-menu-item>
            <el-menu-item index="/contributionReturn">
              <i class="el-icon-wallet"></i>
              <span slot="title">会费返还管理</span>
            </el-menu-item>
            <el-menu-item index="/donationManagement">
              <i class="el-icon-collection"></i>
              <span slot="title">捐赠管理</span>
            </el-menu-item>
          </el-submenu>
          <el-submenu index="4">
            <template slot="title">
                <i class="el-icon-tickets"></i>
                <span slot="title">任务管理</span>
            </template>
            <el-menu-item index="/task">
              <i class="el-icon-date"></i>
              <span slot="title">任务列表</span>
            </el-menu-item>
            <el-menu-item index="/onduty">
              <i class="el-icon-s-grid"></i>
              <span slot="title">值班表</span>
            </el-menu-item>
            <el-menu-item index="/dutymanagement">
              <i class="el-icon-document"></i>
              <span slot="title">值班管理</span>
            </el-menu-item>
            <el-menu-item index="/leave">
              <i class="el-icon-document"></i>
              <span slot="title">请假管理</span>
            </el-menu-item>
          </el-submenu> -->
          <el-submenu index="5">
            <template slot="title">
              <i class="el-icon-s-flag"></i>
              <span slot="title">会议管理</span>
            </template>
            <el-menu-item index="/activityList">
              <i class="el-icon-menu"></i>
              <span slot="title">会议列表</span>
            </el-menu-item>
          </el-submenu>
          <!-- <el-submenu index="6">
            <template slot="title">
              <i class="el-icon-data-analysis"></i>
              <span slot="title">宣传管理</span>
            </template>
            <el-menu-item index="/enterprise">
              <i class="el-icon-tickets"></i>
              <span slot="title">企业列表</span>
            </el-menu-item>
            <el-menu-item index="/desc">
              <i class="el-icon-notebook-1"></i>
              <span slot="title">商会简介</span>
            </el-menu-item>
            <el-menu-item index="/eminent">
              <i class="el-icon-s-custom"></i>
              <span slot="title">杰出人物</span>
            </el-menu-item>
            <el-menu-item index="/style">
              <i class="el-icon-document"></i>
              <span slot="title">商会风采</span>
            </el-menu-item>
            <el-menu-item index="/companyPublicity">
              <i class="el-icon-document"></i>
              <span slot="title">企业宣传</span>
            </el-menu-item>
            <el-menu-item index="/support">
              <i class="el-icon-document"></i>
              <span slot="title">供求管理</span>
            </el-menu-item>
          </el-submenu> -->
          <!-- <el-submenu index="7">
            <template slot="title">
              <i class="el-icon-s-shop"></i>
              <span slot="title">商城管理</span>
            </template>
            <el-menu-item index="/store">
              <i class="el-icon-box"></i>
              <span slot="title">店铺管理</span>
            </el-menu-item>
            <el-menu-item index="/goods">
              <i class="el-icon-goods"></i>
              <span slot="title">商品管理</span>
            </el-menu-item>
            <el-menu-item index="/order">
              <i class="el-icon-s-order"></i>
              <span slot="title">订单管理</span>
            </el-menu-item>
            <el-menu-item index="/settlement">
              <i class="el-icon-collection"></i>
              <span slot="title">结算管理</span>
            </el-menu-item>
          </el-submenu> -->
          <!-- <el-submenu index="8">
            <template slot="title">
              <i class="el-icon-setting"></i>
              <span slot="title">系统管理</span>
            </template>
            <el-menu-item index="/banner">
              <i class="el-icon-picture-outline"></i>
              <span slot="title">轮播图管理</span>
            </el-menu-item>
            <el-menu-item index="/category">
              <i class="el-icon-picture-outline"></i>
              <span slot="title">栏目管理</span>
            </el-menu-item>
            <el-menu-item index="/character">
              <i class="el-icon-set-up"></i>
              <span slot="title">角色管理</span>
            </el-menu-item>
            <el-menu-item index="/permission">
              <i class="el-icon-coordinate"></i>
              <span slot="title">权限管理</span>
            </el-menu-item>
            <el-menu-item index="/integralRule">
              <i class="el-icon-edit-outline"></i>
              <span slot="title">积分规则</span>
            </el-menu-item>
            <el-menu-item index="/administrator">
              <i class="el-icon-user"></i>
              <span slot="title">管理员列表</span>
            </el-menu-item>
            <el-menu-item index="/payRule">
              <i class="el-icon-edit-outline"></i>
              <span slot="title">缴费规则管理</span>
            </el-menu-item>
            <el-menu-item index="/memberRule">
              <i class="el-icon-edit-outline"></i>
              <span slot="title">会员级别管理</span>
            </el-menu-item>
            <el-menu-item index="/webViewPage">
              <i class="el-icon-edit-outline"></i>
              <span slot="title">线下支付页面管理</span>
            </el-menu-item>
          </el-submenu> -->
        </el-menu>
          </vue-scroll>
      </aside>
     <!-- </el-scrollbar> -->
     <vue-scroll :ops="ops">
      <section class="content-container">
        <!-- <el-col :span="24" class="breadcrumb-container">
          <div class="breadcrumb-name">导航名称</div>
          <el-breadcrumb separator-class="el-icon-arrow-right" class="breadcrumb-inner">
							<el-breadcrumb-item>导航一</el-breadcrumb-item>
              <el-breadcrumb-item>表格</el-breadcrumb-item>
						</el-breadcrumb>
        </el-col> -->
        <el-col :span="24" class="content-wrapper">
          <transition name="fade" mode="out-in">
            <router-view></router-view>
          </transition>
        </el-col>
      </section>
     </vue-scroll>
    </el-col>
    <!-- 修改密码 -->
		<el-dialog title="修改密码" :visible.sync="modifyPwdFormVisible" width="30%">
			<el-form :model="modifyPwd" label-width="80px">
        <el-form-item label="原密码">
					<el-input type="password" v-model="modifyPwd.oldPwd" auto-complete="off"></el-input>
				</el-form-item>
        <el-form-item label="新密码">
					<el-input type="password" v-model="modifyPwd.newPwd" auto-complete="off"></el-input>
				</el-form-item>
				<el-form-item label="确认密码">
					<el-input type="password" v-model="modifyPwd.rePwd" auto-complete="off"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button @click.native="modifyPwdFormVisible = false">取消</el-button>
				<el-button type="primary" @click.native="changePassword">提交</el-button>
			</div>
		</el-dialog>
  </el-row>
</template>

<script>
export default {
  data(){
    return{
      ops1:{
        bar:{
          showDelay: 2000,
          size:'10px',
          minSize:'0.5',
          keepShow:true,
          opacity:0
        }
      },
      ops:{
        bar:{
          showDelay: 2000,
          size:'10px',
          minSize:'0.5',
          keepShow:true
        }
      },
      modifyPwdFormVisible:false,
      isCollapse: false,
      modifyPwd:{
        oldPwd:'',
        newPwd:'',
        rePwd: '',
      },
      username:window.localStorage.getItem('user_name'),
    }
  },
  methods:{
    //折叠导航栏
    collapse(){
      this.isCollapse = !this.isCollapse;
    },
    //退出登陆
    loginOut(){
      this.$api.loginOut();
    },
    //弹出修改密码框
    showModifyPwd(){
      this.modifyPwd.oldPwd = '';
      this.modifyPwd.newPwd = '';
      this.modifyPwd.rePwd = '';
      this.modifyPwdFormVisible = true;
    },
    //修改密码提交
    async changePassword(){
      let params = {
        oldpassword:this.modifyPwd.oldPwd,
        newpassword:this.modifyPwd.newPwd,
        repass: this.modifyPwd.rePwd,
      }
      const res = await this.$api.changePassword(params);
      if(res.data.level=='success'){
        this.$message({
          message: "修改成功,请重新登陆",
          type: 'success'
        });
        this.modifyPwdFormVisible = false;
      }else{
        this.$message({
          message: res.data.message,
          type: 'warning'
        });
      }
    },
  }
}
</script>
<style lang='scss' scoped>
  @import '../../assets/css/vars.scss';
  .container{
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    
    .header{
      height: 50px;
      line-height: 50px;
      text-align: center;
      font-size: 24px;
      color: #fff;
      background-color: $color-primary;
      display: flex;
      .logo{
        width: 230px;
        height: 100%;
        font-size: 20px;
        border-right:1px solid #eef1f6;
        transition: all .3s linear;
      }
      .tools{
        height: 100%;
        flex: 4;
        position: relative;
        .tools-content{
          height: 50px;
          line-height: 50px;
          position: absolute;
          left:10px;
          cursor: pointer;
        }
      }
      .user-info{
        height: 100%;
        flex: 1
      }
      .user-info:hover{
        cursor: pointer;
      }
    }
    .main{
      display: flex;
      position: absolute;
      top: 50px;
			bottom: 0px;
      overflow: hidden;
      .aside-menu{
        width: 269px;
        // height: 100vh;
        transition: all .3s linear;
        background:#222d32;
        // overflow-x: hidden;
      }
      .content-container{
        flex: 1;
				padding: 20px;
        // overflow-y: scroll;
        .breadcrumb-container{
          display: flex;
          justify-content: space-between;
          align-items: center;
          .breadcrumb-name{
            font-weight: bolder;
            color: #475669;
          }
        }
      }
    }
    .collapse{
      width: 65px !important;
    }
    .hide{
      display: none !important;
    }
    .dialog-footer{
			text-align: center;
		}
  }
  .fade-enter-active,
.fade-leave-active {
	transition: all .5s ease;
}

.fade-enter,
.fade-leave-active {
	opacity: 0;
  transform: translateX(200px)
}
</style>

<style lang="scss">
@import '../../assets/css/vars.scss';
  .el-menu{
    border-right:1px solid #222d32;
  }
  .el-menu-item.is-active{
    background-color:$navbar-background!important;
  }

</style>
